package com.cdvtc.news.web.api;

import com.cdvtc.news.entity.Category;
import com.cdvtc.news.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags={"新闻分类接口"})
@RestController
@RequestMapping("/api")
public class CategoryApiController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("获取所有新闻分类")
    @GetMapping("categories")
    public List<Category> getAllCategories() {
        return categoryService.getAllCategories();
    }
}
